package cn.bdqn;

/**
 * Hello world!
 *
 */
public class App 
{
    public static void main( String[] args )
    {
        //二分查找法实现
        int target=101;
        int[] arr={13,19,24,28,29,30,34,42,51,84,100};

        int n=arr.length;
        int m=0;
        for (int i = 0,j=n-1; arr[m]!=target ;) {
            if(arr[i]>=arr[j]){
                System.out.println("找不到结果");
                break;
            }
            m= (int) Math.floor((i+j)/2);
            if(target<arr[m]){
                j=m-1;
            } else if (target > arr[m]) {
                i=m+1;
            }else {
                break;
            }
        }
        System.out.println(m);

    }
}
